home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.1 KB | 92 lines | [TEXT/CWIE] |
- // ScreenPartMaker.cp
-
- #ifndef ScreenPartMaker_h
- #include "ScreenPartMaker.h"
- #endif
- #ifndef NoScreenPart_h
- #include "NoScreenPart.h"
- #endif
- #ifndef Assert_h
- #include "Assert.h"
- #endif
- #ifndef SingleAllocator_h
- #include "SingleAllocator.h"
- #endif
- #ifndef MenuBarScreenPart_h
- #include "MenuBarScreenPart.h"
- #endif
- #ifndef SystemWindowScreenPart_h
- #include "SystemWindowScreenPart.h"
- #endif
- #ifndef WindowScreenPart_h
- #include "WindowScreenPart.h"
- #endif
- #ifndef AbstractWindow_h
- #include "AbstractWindow.h"
- #endif
-
- #define MaxSize2(A,B) ( (sizeof(A)>sizeof(B)) ? sizeof(A) : sizeof(B) )
- #define MaxSize4(A,B,C,D) ( (MaxSize2(A,B)>MaxSize2(C,D) ? MaxSize2(A,B) : MaxSize2(C,D) ) )
-
- #define maxPartSize MaxSize4( NoScreenPart, MenuBarScreenPart, SystemWindowScreenPart, WindowScreenPart )
-
-
- ScreenPart& ScreenPartMaker::MakeScreenPart( PointObject p )
- {
- WindowPtr window = 0;
- int16 part = FindWindow( p, &window );
-
- switch ( part )
- {
- case inGrow:
- Assert( window == FrontWindow() );
- break;
-
- case inGoAway:
- case inZoomIn:
- case inZoomOut:
- if ( window != FrontWindow() )
- part = inDrag;
- break;
- }
-
- static SingleAllocator< ScreenPart, maxPartSize > storage;
- storage.DeleteAll();
-
- switch ( part )
- {
- case inDesk:
- return *new( storage ) NoScreenPart;
-
- case inMenuBar:
- return *new( storage ) MenuBarScreenPart;
-
- case inSysWindow:
- return *new( storage ) SystemWindowScreenPart( window );
-
- case inContent:
- return *new( storage ) WindowScreenPart( window, &AbstractWindow::ClickContent );
-
- case inDrag:
- return *new( storage ) WindowScreenPart( window, &AbstractWindow::ClickDrag );
-
- case inGrow:
- return *new( storage ) WindowScreenPart( window, &AbstractWindow::ClickGrow );
-
- case inGoAway:
- return *new( storage ) WindowScreenPart( window, &AbstractWindow::ClickClose );
-
- case inZoomIn:
- return *new( storage ) WindowScreenPart( window, &AbstractWindow::ClickZoomIn );
-
- case inZoomOut:
- return *new( storage ) WindowScreenPart( window, &AbstractWindow::ClickZoomOut );
-
- default:
- Assert( 0 );
- break;
- }
-
- return *new( storage ) NoScreenPart;
- }
-